<script type="text/javascript">
$(document).ready(function(e) {
    $link = "<?php echo baseurl; ?>";
	$("#submit").click(function(){
		user=$("#user").val();
		pass=$("#pass").val();
		if(user==""||pass==""){
			$("#errors").html("Bạn chưa nhập đủ thông tin!");
			return false;
		}else{
			$.ajax({
				"url":"functions/process.php",//where data receive
				"type":"post",//data transfer method
				"data":"user="+user+"&pass="+pass,//data need transfer to PHP
				"async":false,
				success: function(result){//receive data from PHP
					if(result==1){
						$("#errors").html("Sai username hoặc password");
						return false;
					}else{
						$("#errors").html("<img src='"+$link+"images/loading/loading.gif'/>Đang load dữ liệu");
						setTimeout(function(){
							$("#showuser").html(result);
						},1000);
					}
				}
			});
		}
	});
});
</script>
<form action="" method="post">
	
</form>
<div class="users">
  <div id="showuser">
  <?php if(isset($_SESSION['ses_name'])){ ?>
  <?php 
  	echo "<div style='padding:10px 7px'>";
	echo "Xin chào ".$_SESSION['ses_name'].". ";
	echo "<a href='#'>Thông tin. </a>";
	echo "<a href='#'>Đơn hàng của bạn.</a>";
  ?>
  <?php
	echo "</div>";
  ?>
  <?php }else{ ?>
  <div class="usercontent">
    <table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>Tài khoản
          <input type="text" name="user" id="user" size="10" /></td>
        <td>Mật khẩu
          <input type="password" name="pass" id="pass" size="10" /></td>
        <td><input type="button" id="submit" value="Đăng nhập">
          <a class="register" href="<?php echo baseurl; ?>?page=register">Đăng ký</a></td>
        <td><span id="errors" style="color:#F00"></span></td>
       </tr>
	</table>
    </form>
  </div>
  <?php } ?>
  </div>
</div>